/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package data.impl;

import java.util.Date;

import data.DataFactory;
import data.DataPackage;
import data.HeartRateSample;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Heart Rate Sample</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link data.impl.HeartRateSampleImpl#getHeartRate <em>Heart Rate</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class HeartRateSampleImpl extends DataSampleImpl implements HeartRateSample {
	/**
	 * The default value of the '{@link #getHeartRate() <em>Heart Rate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHeartRate()
	 * @generated
	 * @ordered
	 */
	protected static final int HEART_RATE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getHeartRate() <em>Heart Rate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHeartRate()
	 * @generated
	 * @ordered
	 */
	protected int heartRate = HEART_RATE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected HeartRateSampleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DataPackage.Literals.HEART_RATE_SAMPLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getHeartRate() {
		return heartRate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setHeartRate(int newHeartRate) {
		int oldHeartRate = heartRate;
		heartRate = newHeartRate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataPackage.HEART_RATE_SAMPLE__HEART_RATE, oldHeartRate, heartRate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DataPackage.HEART_RATE_SAMPLE__HEART_RATE:
				return getHeartRate();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DataPackage.HEART_RATE_SAMPLE__HEART_RATE:
				setHeartRate((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DataPackage.HEART_RATE_SAMPLE__HEART_RATE:
				setHeartRate(HEART_RATE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DataPackage.HEART_RATE_SAMPLE__HEART_RATE:
				return heartRate != HEART_RATE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (heartRate: ");
		result.append(heartRate);
		result.append(')');
		return result.toString();
	}
	
	public HeartRateSample clone()
	{
		HeartRateSample result = DataFactory.eINSTANCE.createHeartRateSample();
		result.setHeartRate(this.getHeartRate());
		result.setTimestamp(new Date(this.getTimestamp().getTime()));
		return result;
	}

} //HeartRateSampleImpl
